package com.br.sc.vendas.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

import com.actionbarsherlock.app.SherlockActivity;

public class MainActivity extends SherlockActivity implements OnClickListener
{

	@Override
	protected void onCreate ( Bundle savedInstanceState )
	{
		super.onCreate( savedInstanceState );
		setContentView( R.layout.activity_main );

		findViewById( R.main.btCadastrarCliente ).setOnClickListener( this );
		findViewById( R.main.btCadastroPedido ).setOnClickListener( this );
		findViewById( R.main.btListarCliente ).setOnClickListener( this );
		findViewById( R.main.btPedidosDoCliente ).setOnClickListener( this );
		findViewById( R.main.btEnviarEmail ).setOnClickListener( this );

		final Banco banco = new Banco( );
		banco.criaBanco( this );
		banco.verificaSeExisteCidadesCadastradas( MainActivity.this );
	}

	@Override
	public void onClick ( View view )
	{
		Intent intent = null;

		if ( view.getId( ) == R.main.btCadastrarCliente )
			intent = new Intent( this, CadastroClienteActivity.class );
		else if ( view.getId( ) == R.main.btCadastroPedido )
			intent = new Intent( this, CadastroPedidosActivity.class );
		else if ( view.getId( ) == R.main.btListarCliente )
			intent = new Intent( this, ListaClientesActivity.class );
		else if ( view.getId( ) == R.main.btPedidosDoCliente )
			intent = new Intent( this, ListaPedidosActivity.class );
		else if ( view.getId( ) == R.main.btEnviarEmail ) intent = new Intent( this, ListaPedidosEmailActivity.class );

		startActivity( intent );

	}
}
